Skip to main content

Approving Paymaster in Axir Smart Account

Overview

This guide explains how to approve different paymasters for gas fee payment in your Axir smart account.

Notes:

  • The Smart Contract Wallet needs to approve the AXRERC20 Paymaster to spend its fee tokens to be able to use AXR ERC20 Paymaster.
  • This first approve tx cannot be done with AXRERC20 Paymaster because of how pimlico bundlers behave currently , so either don't use paymasters or use AXRPaymaster for this first approve tx.

Prerequisites

import { AxirCore } from "axr-erc4337-sdk";
import { ethers } from "ethers";

// Network-specific paymaster addresses
const PAYMASTERS = {
sepolia: {
pimlico: '0x000000000041F3aFe8892B48D88b6862efe0ec8d',
axr: '0x45576D2958408B2736C7254369DC04A4EE130Ac4',
erc20Token: '0xE61A8c5ccbd49d5a31958Cf59ddb4EA1914AF149'
},
baseSepolia: {
pimlico: '0x00000000002E3A39aFEf1132214fEee5a55ce127',
axr: '0x2ee7CbDDcb0774280B533894789a627921E1c6EA',
erc20Token: '0x036CbD53842c5426634e7929541eC2318f3dCF7e'
}
};

Paymaster Approval Implementation

1. Approving AXR Paymaster

const smartWallet = new AxirCore(
PRIVATE_KEY,
RPC_URL,
BUNDLER_URL,
BigInt(0),
'sepolia'
);

// Approve AXR Paymaster
await smartWallet.tokenApprove(
PAYMASTERS.sepolia.erc20Token, // token address
PAYMASTERS.sepolia.pimlico, // paymaster address
ethers.parseEther('100'), // approval amount
undefined, // additional data
true, // use paymaster
'AXRPaymaster' // paymaster type
);

2. Approving AXR ERC20 Paymaster

// Approve AXR Paymaster
await smartWallet.tokenApprove(
PAYMASTERS.sepolia.erc20Token,
PAYMASTERS.sepolia.axr,
ethers.parseEther('100'),
undefined,
true,
'AXRERC20Paymaster'
);